﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Problem12
{
    class Program
    {
        static void Main(string[] args)
        {
            long currentNumber = 1;
            long currentTriangle = 0;

            SortedSet<long> divisors = new SortedSet<long>();

            while (divisors.Count<= 500)
            {
                divisors.Clear();
                currentTriangle += currentNumber;

                for (long i = 1; i <= Math.Floor(Math.Sqrt(currentTriangle)); i++)
                {
                    if (currentTriangle % i == 0)
                    {
                        divisors.Add(i);
                        divisors.Add(currentTriangle / i);
                    }
                }

                currentNumber++;
            }

            Console.WriteLine(currentTriangle);
            Console.ReadKey();
        }
    }
}
